<?php
    session_start();
    include("includes/checklogged.php");
    include("includes/mysql_connect.inc.php");
    check_logged();
?>

<?php include('includes/header.php'); ?>
<?php 
  if ($_SESSION["logged"] == "admin"){
    include('includes/nav.php'); 
  }
  else{ 
	include('includes/nav2.php');
}?> 
<script language="javascript" type="text/javascript" src="java/datetimepicker.js"></script>

<div id="content">
<?php 
include("includes/userfunctions.php");
include("includes/datefunctions.php");
//=========================================================================================================================================
function validateThisForm()
{
   global $errmsg;
   $errmsg = '';

   if (strlen($_POST["fromdate"] == 0) && strlen($_POST["todate"] == 0))
   {
      $errmsg = "No Date Selected...";
      return (FALSE);
   }
   
      if (strlen($_POST["fromdate"] > 0) && strlen($_POST["todate"] > 0))
   {
      $fromdate = convertDatePicker($_POST["fromdate"],"MMDDYYYY");
      $fromdatebin = strtotime($fromdate);

      $todate = convertDatePicker($_POST["todate"],"MMDDYYYY");
      $todatebin = strtotime($todate);

      if ($fromdatebin > $todatebin)
      {
         $errmsg = "Date error...";
         return (FALSE);
      }
   }
   return (TRUE);
}
//=========================================================================================================================================
if (!isset ($_POST["firstname"]))
{
   showEmpList(CONTINUEE, TIMEFUNCTION);
}
else
{
   if (isset ($_POST["lastname"]) && validateThisform())
   {
         addEmpTimeToDB();
         $errmsg = EmpSaved;
         EmpTimeList();
   }
   else
   {
      showUserForm3(TIMEINEMP, TIMEINEMP);
   }
}
//=========================================================================================================================================
?>
</div> <!-- end #content -->

<?php 
  if ($_SESSION["logged"] == "admin"){
    include('includes/sidebar.php'); 
  }
  else{ 
	include('includes/sidebar3.php');
  }?> 
<?php include('includes/footer.php'); ?>
